<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>盘点批号列表</title>
		<link rel="stylesheet" href="__PEAR__/component/pear/css/pear.css" />
		<style>
		.layui-input{width:150px;}
		.layui-form-label{width:auto;}
		.layui-form-item .layui-input-inline{width: 150px;}
		.inputdiv{display:flex;height: 38px;line-height: 38px;}
		.inputdiv i{position:absolute;right:10px;}
		.layui-table-cell .layui-table-link {color: #ff6a08!important;}}
		</style>
	</head>
	<body class="pear-container">
		<div class="layui-card">
			<div class="layui-card-body">
				<form class="layui-form" action="">
					<div class="layui-form-item">
						<div class="layui-form-item layui-inline">
							<label class="layui-form-label">盘点批号</label>
							<div class="layui-input-inline">
								<input type="text" name="sheet_no" placeholder="" value="" class="layui-input">
							</div>
						</div>
						
						<div class="layui-form-item layui-inline">
							<label class="layui-form-label">仓库门店</label>
							<div class="layui-input-inline">
								<select name="branch_no" lay-filter="branch_no" lay-search>
									<option value="">请选择...</option>
									{volist name="wareHouse" id="vo"}
									<option value="{$vo['branch_no']}">{$vo['branch_name']}</option>
									{/volist}
								</select>
							</div>
						</div>
						
						<div class="layui-form-item layui-inline">
							<button class="pear-btn pear-btn-md pear-btn-primary" lay-submit lay-filter="pdsheet-query">
								<i class="layui-icon layui-icon-search"></i>
								查询
							</button>
							<button type="reset" class="pear-btn pear-btn-md" onclick="resetForm()">
								<i class="layui-icon layui-icon-refresh"></i>
								重置
							</button>
						</div>
					</div>
				</form>
			</div>
		</div>
		<div class="layui-card">
			<div class="layui-card-body" id="pdsheet-body">
				<table id="pdsheet-table" lay-filter="pdsheet-table"></table>
			</div>
		</div>
		<script type="text/html" id="pdsheet-toolbar">
			<button class="pear-btn pear-btn-primary pear-btn-md" lay-event="add">
		        <i class="layui-icon layui-icon-add-1"></i>
		        新建盘点批号
		    </button>
		</script>
		<script type="text/html" id="approveTpl">
  			{{#  if(d.approve_flag ==1){ }}
    				<a class="layui-table-link">已审核</a>
  				{{#  } else { }}
    				未审核
  			{{#  } }}
		</script>
		<script src="__STATIC__/lib/layui/layui.js"></script>
		<script src="__PEAR__/component/pear/pear.js"></script>
		<script src="__STATIC__/js/admin/common.js"></script>
		<script>
			var branch_no="";
			var oper_range="";
			var _layerIndex=null;
			
			layui.use(['table', 'form', 'jquery','common','laydate'], function() {
				let table = layui.table;
				let form = layui.form;
				let $ = layui.jquery;
				let common = layui.common;
				let laydate = layui.laydate;
				
			  	laydate.render({
					    elem: '#date-range'
					    ,range: ['#start-date', '#end-date']
			    });

				let DATA_PATH = "/{$MODULE_NAME}/check/pdsheet/";

				let cols = [
					[
						{
							title: '序号',
							field: 'rowIndex',
							align: 'left',
							width: 80
						},
						{
							title: '盘点批号',
							field: 'sheet_no',
							align: 'left',
							width: 180
						},
						{
							title: '盘点仓库',
							field: 'branch_name',
							align: 'left',
							width: 100
						},
						{
							title: '创建者',
							field: 'oper_name',
							align: 'left',
							width: 100
						},
						{
							title: '是否审核',
							field: 'approve_flag',
							align: 'left',
							templet:'#approveTpl',
							width: 100
						},
						{
							title: '备注',
							field: 'memo',
							align: 'left',
							width: 150
						}
					]
				]

				table.render({
					elem: '#pdsheet-table',
					url: DATA_PATH+"getlist",
					page: true,
					cols: cols,
					height:600,
					skin: 'line',
					toolbar: '#pdsheet-toolbar',
					defaultToolbar: [],
					done:function(res, curr, count){
						var _width=$("#pdsheet-body").width();
						$("#pdsheet-table").css("width", _width);
					}
				});
				
				form.on('submit(pdsheet-query)', function(data) {
					table.reload('pdsheet-table', {
						where: data.field,
						page:{curr:1}
					})
					return false;
				});
				
				table.on('toolbar(pdsheet-table)', function(obj) {
					if (obj.event === 'add') {
						window.add();
					} else if (obj.event === 'batchRemove') {
						window.batchRemove(obj);
					}
				});
				
				window.add=function(){
					layer.open({
						type: 2,
						title: "新建盘点批号",
						shade: 0.1,
						area: ['600px', '450px'],
						content: DATA_PATH + 'addSheetno.html'
					});
				}
				
				window.refresh = function(param) {
					table.reload('pdsheet-table');
				}
			})
		</script>
	</body>
</html>
